<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

<script type="text/javascript">
    var errorOpts = {
        msg : "<bean:message key="ticket.read.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="ticket.read.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="ticket.read.msgStatus" bundle="errors"/>"
    };
    var loadNoteOpts = {
        msg : "<bean:message key="note.load.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="note.load.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="note.load.msgStatus" bundle="errors"/>"
    };
	var changePriorityOpts = {
		msg : "<bean:message key="priority.change.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="priority.change.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="priority.change.msgStatus" bundle="errors"/>"
	};
	var changeStatusOpts = {
		msg : "<bean:message key="status.change.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="status.change.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="status.change.msgStatus" bundle="errors"/>"
	};
    var errorLoadDialogAttachmentOpts = {
        msg : "<bean:message key="ticket.loadAttachmentDialog.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="ticket.loadAttachmentDialog.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="ticket.loadAttachmentDialog.msgStatus" bundle="errors"/>"
    };
    var errorLoadTicketAttachmentListOpts = {
        msg : "<bean:message key="ticket.loadAttachmentList.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="ticket.loadAttachmentList.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="ticket.loadAttachmentList.msgStatus" bundle="errors"/>"
    };
</script>

<c:forEach items="${requestScope.tickets}" var="entry">
<div class="result">
	<input id="ticketID-${entry.ticketID}" type="hidden" value="${entry.ticketID}" name="ticketID-${entry.ticketID}"/>
	<ul class="itemResultNW">
	    <li>
	        <p class="assigned" title="${entry.openBy.profile.firstName} ${entry.openBy.profile.lastName}">${entry.openBy.username}</p>
	    </li>
	    <li>
	        <p class="openDate">${entry.openDate}</p>
	    </li>
	    <li>
	        <p class="closeDate">${entry.closeDate}</p>
	    </li>
	    <li>
            <p class="category" title="${entry.subCategory.description}">${entry.subCategory.name}</p>
        </li>
	    <li>
	        <p class="status" title="${entry.status.description}">
	        	<select name="statusType" class="element select" id="status-${entry.ticketID}" onchange="changeTicketStatus('${pageContext.request.contextPath}/operator/changeticketstatus.do', '${entry.ticketID}');">
				    <c:forEach items="${requestScope.status}" var="item">
				         <option value="${item.name}" title="${item.description}" <c:if test="${item.name eq entry.status.name}">selected="selected"</c:if>>${item.name}</option>
				    </c:forEach> 
				</select>
	        </p>
	    </li>
	    <li>
	        <p class="priority" title="${entry.priority.description}">
	        	<select name="priorityType" class="element select" id="priority-${entry.ticketID}" onchange="changeTicketPriority('${pageContext.request.contextPath}/operator/changeticketpriority.do', '${entry.ticketID}');">
				    <c:forEach items="${requestScope.priorities}" var="item">
                        <option value="${item.name}" title="${item.description}" <c:if test="${item.name eq entry.priority.name}">selected="selected"</c:if> >${item.name}</option>
                    </c:forEach> 
                </select>
	        </p>
	    </li>
	    <li>
	        <p class="subject">${entry.subject}</p>
	    </li>
	    <li>
	        <p id="contains-${entry.ticketID}" class="contains">${entry.description}</p>
	        <a class="ReadMoreTicket" href="javascript:showReadingBox('${pageContext.request.contextPath}/ticket/loadTicket.do',${entry.ticketID},'<bean:message key="ticket.boxtitle" bundle="ticket"/>')"><bean:message key="ticket.content.read" bundle="ticket"/></a>
	    </li>
	    <li class="liAttachment" id="attachment-${entry.ticketID}">
	        <c:forEach items="${entry.attachment}" var="attachment">
	            <p class="attachment">
	               <a href="${pageContext.request.contextPath}/file/download.do?attachmentID=${attachment.attachmentID}">
                    <img class="imgPanelAttachment" src="${pageContext.request.contextPath}/common/loadimg.do?mimeType=${attachment.fileContentType}" alt="Download ${attachment.fileName}" title="Download ${attachment.fileName}" />
	               </a>
	            </p>
	        </c:forEach>
	    </li>
	 	<li class="boxNote" id="boxNote-${entry.ticketID}">
			<p id="noteid-${entry.ticketID}" class="note">
			     <a class="aNote" href="javascript:loadNote('${pageContext.request.contextPath}/ticket/loadticketnote.do', '${entry.ticketID}');">
			     	<bean:message key="ticket.opennote" bundle="ticket"/>
			     </a> | 
			     <c:if test="${entry.device ne null}">
				     <a class="aDevice" href="javascript:showReadingBox('${pageContext.request.contextPath}/operator/loadfeatures.do',${entry.device.deviceID},'<bean:message key="ticket.device.devicebox.title" bundle="ticket"/>')">
				     	<bean:message key="ticket.device.viewdevice" bundle="ticket"/>
				     </a> |
			     </c:if>
			     <a id="loadAttachment" class="aNote" href="javascript:loadAttachmentFile('${pageContext.request.contextPath}/ticket/activeticketattachment.do', '${entry.ticketID}', '<bean:message key="ticket.attachmentfile" bundle="ticket"/>');">
			       	<bean:message key="ticket.attachment.add" bundle="ticket"/>
			     </a>
			</p>
			<div id="NoteWrapper-${entry.ticketID}"></div>
		</li>
	</ul>
</div>
</c:forEach>